package com.cn.execption;

import com.cn.code.CodeEnum;
import com.cn.response.BaseResponse;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.RestControllerAdvice;

@RestControllerAdvice(annotations = RestController.class)
@Slf4j
public class ControllerExecptionHandler {
    @ExceptionHandler(Exception.class)
    public BaseResponse<Void> handler(Exception e){
        System.out.println("进入异常业务"+e.getMessage());
        log.info("进入异常业务",e.getMessage());
        return BaseResponse.fail(CodeEnum.SUCCESS.getCode(), CodeEnum.SUCCESS.getMesssage());
    }
}
